﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:viewmodel="clr-namespace:DDU.ViewModel;assembly=DDU.ViewModel"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:UX="clr-namespace:DDU.UX;assembly=DDU.UX" 
    xmlns:Converters="clr-namespace:DDU.Converters;assembly=DDU.Converters"
    x:Class="DDU.Curriculum.Views.CoursesView" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter"/>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        
        <Style TargetType="ListBoxItem" x:Key="style_schedule">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid Margin="0,12">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Name="staclPanel">
                                <TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextTitle2Style}"/>
                                <TextBlock Style="{StaticResource PhoneTextSubtleStyle}">
                                    <Run Text="{Binding StartTime, StringFormat=\{0:HH:mm\}}"/>
								    <Run Text=" - "/>
								    <Run Text="{Binding EndTime, StringFormat=\{0:HH:mm\}}"/>
                                </TextBlock>
                            </StackPanel>

                            <UX:UXPathButton IconPath="{StaticResource PATH_ICON_DETAIL}" 
                                             Tag="{Binding Guid}"
                                             Margin="12,0" Grid.Column="1" 
                                             Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" 
                                             Click="GotoEditView" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:CourseViewModel/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/Assets/back.png"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <controls:Pivot Title="{StaticResource IDS_APP_NAME}" SelectedIndex="{Binding PivotIndex, Mode=OneWay}">
            <controls:PivotItem Header="星期日">
                <Grid>
                    <ListBox ItemContainerStyle="{StaticResource style_schedule}" ItemsSource="{Binding ItemsOfSunday}"/>
                </Grid>
            </controls:PivotItem>
            
            <controls:PivotItem Header="星期一">
                <Grid>
                    <ListBox ItemContainerStyle="{StaticResource style_schedule}" ItemsSource="{Binding ItemsOfMonday}"/>
                </Grid>
            </controls:PivotItem>

            <!--Pivot item two-->
            <controls:PivotItem Header="星期二">
                <Grid>
                    <ListBox ItemContainerStyle="{StaticResource style_schedule}" ItemsSource="{Binding ItemsOfTuesday}"/>
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="星期三">
                <Grid>
                    <ListBox ItemContainerStyle="{StaticResource style_schedule}" ItemsSource="{Binding ItemsOfWednesday}"/>
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="星期四">
                <Grid>
                    <ListBox ItemContainerStyle="{StaticResource style_schedule}" ItemsSource="{Binding ItemsOfThursday}"/>
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="星期五">
                <Grid>
                    <ListBox ItemContainerStyle="{StaticResource style_schedule}" ItemsSource="{Binding ItemsOfFriday}"/>
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="星期六">
                <Grid>
                    <ListBox ItemContainerStyle="{StaticResource style_schedule}" ItemsSource="{Binding ItemsOfSaturday}"/>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>

        <Grid  Grid.Row="1" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <toolkit:ListPicker ExpansionMode="FullScreenOnly" FullModeHeader="选择学期" ItemsSource="{Binding ItemsOfSemesters}" SelectedItem="{Binding SelectedSemester, Mode=TwoWay}">
                <toolkit:ListPicker.ItemTemplate>
                    <DataTemplate>
                        <TextBlock >
                                    <Run Text="{Binding EducationLevel, Converter={StaticResource EnumTranslateConverter}}"/>
                                    <Run Text=" "/>
                                    <Run Text="{Binding Grade, Converter={StaticResource EnumTranslateConverter}}"/>
                                    <Run Text=" "/>
                                    <Run Text="{Binding Term, Converter={StaticResource EnumTranslateConverter}}"/>
                        </TextBlock>
                    </DataTemplate>
                </toolkit:ListPicker.ItemTemplate>
                <toolkit:ListPicker.FullModeItemTemplate>
                    <DataTemplate>
                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Margin="0,12">
                                    <Run Text="{Binding EducationLevel, Converter={StaticResource EnumTranslateConverter}}"/>
                                    <Run Text=" "/>
                                    <Run Text="{Binding Grade, Converter={StaticResource EnumTranslateConverter}}"/>
                                    <Run Text=" "/>
                                    <Run Text="{Binding Term, Converter={StaticResource EnumTranslateConverter}}"/>
                        </TextBlock>
                    </DataTemplate>
                </toolkit:ListPicker.FullModeItemTemplate>
            </toolkit:ListPicker>
            
            <UX:UXPathButton Angle="45" IconPath="{Binding Mode=OneWay, Source={StaticResource PATH_ICON_CLOSE}}" Uri="/Views/CourseAddView.xaml" Margin="12" VerticalAlignment="Bottom" Grid.Column="1"/>

        </Grid>
    </Grid>

</phone:PhoneApplicationPage>